<?php

/** 返回input radio的html代码
 * @param string $name          input的name
 * @param array $option
 *
 * @param null $data
 * @return string
 */
function j_input_radio($name, $option, $data = null){
    $str = '';

    foreach($option as $key => $value){
        $checked = '';
        if($key == $data){
            $checked = 'checked';
        }

        $str .= <<<EOF
        <input  value="{$key}" {$checked} name="{$name}" type="radio" /> {$value}
EOF;

    }

    return $str;

}


function j_input_select($name, $option, $data = null){
    $str = '<select name="'.$name.'" class="form-control">';

    foreach($option as $key => $value){
        $selected = '';
        if($key == $data){
            $selected = 'selected="selected"';
        }

        $str .= <<<EOF
          <option {$selected} value="{$key}">{$value}</option>
EOF;
    }

    $str .= '</select>';
    return $str;
}




?>